using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BHXH.Core.Domain;
using BHXH.Core.IService;
using FX.Data;
using NHibernate;

namespace BHXH.Core.ServiceImp
{
    public class hs_attachfileService: BaseService<hs_attachfile ,int>,Ihs_attachfileService
    {
        ISession mySession;
        public hs_attachfileService(string sessionFactoryConfigPath)
            : base(sessionFactoryConfigPath)
        {}
        public IList<hs_attachfile> GetAll_hs_attachfile()
        {
            var a = GetAll();
            return a;
        }

        public void Update_hs_attachfile(hs_attachfile hs)
        {
            hs_attachfile hsnew = new hs_attachfile();
            hsnew = hs;
            using (mySession = this.NHibernateSession.SessionFactory.OpenSession())
            {
                mySession.SaveOrUpdate(hs);
                CommitChanges();
                mySession.Flush();
            }
        }

        public bool Add_hs_attachfile(hs_attachfile hs)
        {

            using (mySession = this.NHibernateSession.SessionFactory.OpenSession())
            {
                mySession.Save(hs);
                return true;
            }
        }

        public int Delete_hs_attachfile(string ID)
        {
            using (mySession = this.NHibernateSession.SessionFactory.OpenSession())
            {
                int a = mySession.CreateQuery("DELETE FROM hs_attachfile hs WHERE hs.ID=:id")
                    .SetParameter("id", int.Parse(ID))
                    .ExecuteUpdate();
                CommitChanges();
                mySession.Clear();
                return a;
            }
        }
    }

}